package com.test.prolenders.config_prolenders;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;

import androidx.core.content.ContextCompat;

public class PermissionConfig_prolenders {

    public static final int PermissionCode_All = 128;
    public static final int PermissionCode_Camera = 919;
    public static final int PermissionCode_PhoneState = 986;
    public static final int PermissionCode_Sms = 824;
    public static final int PermissionCode_Home = 429;


    public static final String[] Permissions_All = new String[]{"android.permission.CAMERA","android.permission.READ_PHONE_STATE","android.permission.READ_SMS"};
    public static final String[] Permissions_Start = new String[]{"android.permission.READ_PHONE_STATE","android.permission.READ_SMS"};

    public static final String Permission_Camera = "android.permission.CAMERA";
    public static final String Permission_Phonestate = "android.permission.READ_PHONE_STATE";
    public static final String Permission_Sms = "android.permission.READ_SMS";

    public static boolean checkAllPermission(Activity activity){
        for (String permission:Permissions_All){
            if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(activity,permission)) return false;
        }
        return true;
    }

    public static boolean checkStartPermission(Activity activity){
        for (String permission:Permissions_Start){
            if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(activity,permission)) return false;
        }
        return true;
    }

    public static boolean checkPermissions(Context context, String... permissions){
        for (String permission:permissions){
            if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(context,permission)) return false;
        }
        return true;
    }


    public static boolean checkCameraPermission(Activity activity){
        return PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(activity, Permission_Camera);
    }

    public static boolean checkPhonestatePermission(Activity activity){
        return PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(activity, Permission_Phonestate);
    }

    public static boolean checkSmsPermission(Activity activity){
        return PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(activity, Permission_Sms);
    }

}
